import { lazy } from "react";
import {createBrowserRouter, Navigate} from "react-router-dom"
import Zhu from "../pages/Zhu/Zhu";

let Home=lazy(()=> import("../pages/Home/Home"));
let List=lazy(()=> import("../pages/List/List"));
let Detail=lazy(()=> import("../pages/Detail/Detail"));
let Table=lazy(()=> import("../pages/Table/Table"));
let Order=lazy(()=> import("../pages/Order/Order"));
let Error=lazy(()=> import("../pages/Error/Error"));

export const homeRoutes=[
    {
        path:"/zhu/home",
        element:<Home></Home>,
        title:"首页"
    },
    {
        path:"/zhu/list",
        element:<List></List>,
        title:"列表"
    },
    {
        path:"/zhu/order",
        element:<Order></Order>,
        title:"订单",
        children:[
            {
                path:"/zhu/order/table",
                element:<Table></Table>,
                title:"表格"
            },
        ]
    },
]

let routes=createBrowserRouter([
    {
        path:"/",
        element:<Navigate to={"/zhu"}></Navigate>
    },
    {
        path:"/zhu",
        element:<Zhu></Zhu>,
        children:homeRoutes
    },
    {
        path:"/detail",
        element:<Detail></Detail>
    },
    {
        path:"*",
        element:<Error></Error>
    },
])
export default routes